/**
 * Created by abdulazizalonizi on 8/1/17.
 */
import java.io.*;
import java.util.Scanner;
public class Task5 {
    public static void main (String[] args)
    {
        try {
            FileInputStream fis = new FileInputStream("grades.txt");
            Scanner kb = new Scanner(fis);
            double [][]grades = new double [5][5];
            int [] std = new int [5];

            for (int i = 0 ; i < std.length ; i++)
            {
                std[i] = kb.nextInt();
               //System.out.println(std[i]);
                for (int j = 0 ; j < grades[i].length ;j++)
                {
                    grades[i][j] = kb.nextDouble();
                    //System.out.print(grades[i][j]+" ");

                }
                //System.out.println("");
                //kb.nextLine();
            }


            double [] avg = new double [std.length];
            double [] max = new double [std.length];
            double [] quizAvg = new double [grades[0].length];

            for (int i = 0 ; i < avg.length ; i++)
            {
                for (int j =0 ; j <grades[i].length ; j++)
                {
                    avg[i] += grades[i][j];

                    if (grades[i][j] >max[i])
                    {
                        max[i] = grades[i][j];
                    }

                    quizAvg[i] += grades[j][i];


                }
                quizAvg[i] = quizAvg[i]/grades[i].length;
                avg[i] = avg[i]/grades[i].length;
            }
            System.out.println("ID          Quiz Average            Max Quiz Grade");

            for (int i = 0; i <std.length ; i++)
            {
                System.out.println(std[i] +"            " +avg[i]+"             "+max[i]);


            }
            System.out.println("QZ1\t    QZ2\t   QZ3\t   QZ4\t   QZ5");
            for (int i =0 ; i<quizAvg.length;i++)
            {
                System.out.print(quizAvg[i]+"\t");
            }


        }
        catch(Exception me )
        {
            System.out.println("Exception found");

        }

    }
}
